package com.yueke.gemini.snake;


import java.awt.*;


/**
 * 小蛇
 */
public class Snake {
    private Node head = null;
    private Node tail = null;
    int size =0 ;
    private Node n =new Node (20,15,Dir.A);
    Yard y;
    Snake(Yard y){
        head = n;
        tail =n;
        size =1;
        this.y = y;
    }

    public void draw(Graphics g){
        if(size <= 0)return;

        for(Node n = head; n != null; n = n.next){
            n.draw(g);
        }

    }




    public class Node{
        int w = Yard.BLOCK_SIZE;
        int s = Yard.BLOCK_SIZE;
        int row,col;

        Dir dir = Dir.A;

        Node next = null;
        Node prep = null;

        Node(int row,int col,Dir dir){
            this.col = col;
            this.row = row;
            this.dir = dir;

        }
        void draw(Graphics g){
            Color c =g.getColor();
            g.setColor(Color.blue);
            g.fillRect(Yard.BLOCK_SIZE*col, Yard.BLOCK_SIZE*row, w, s);
            g.setColor(c);
        }

    }
}
